home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / memory / cmpmem.a < prev    next >
Text File  |  1994-02-01  |  1KB  |  80 lines

  1.  
  2.         ;   CMPMEM.A
  3.         ;
  4.         ;   (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  5.  
  6.         section text,code
  7.  
  8.         ;   CMPMEM (s1, s2, len)
  9.         ;   MEMCMP (s1, s2, len)    ANSI
  10.         ;   BCMP   (s1, s2, len)    UNIX
  11.         ;        A0    A1  D0        internal args
  12.         ;     4(sp) 8(sp) 12(sp)
  13.  
  14.         xdef    _cmpmem
  15.         xdef    _bcmp
  16.         xdef    _memcmp
  17.         xdef    @cmpmem
  18.         xdef    @bcmp
  19.         xdef    @memcmp
  20.         xdef    _hyper_cmpmem
  21.         xdef    _hyper_bcmp
  22.         xdef    _hyper_memcmp
  23.  
  24.  
  25. _hyper_memcmp:
  26. _hyper_cmpmem:
  27. _hyper_bcmp:
  28. _memcmp:
  29. _cmpmem:
  30. _bcmp:
  31.         move.l    4(sp),A0
  32.         move.l    8(sp),A1
  33.         move.l    12(sp),D0
  34. @memcmp:
  35. @cmpmem:
  36. @bcmp:
  37.         move.l    D0,D1
  38.         move.w    A0,D0        ; not word aligned adress.
  39.         lsr.l    #1,D0
  40.         bcs    xcmbyte
  41.         move.w    A1,D0
  42.         lsr.l    #1,D0
  43.         bcs    xcmbyte
  44.  
  45.         move.l    D1,D0        ; save D1
  46.         lsr.l    #2,D1        ; # of longwords to compare
  47.  
  48. xcmlong     subq.l    #1,D1
  49.         bcs    xcmlbreak
  50. xcmlloop    cmpm.l    (A0)+,(A1)+
  51.         dbne    D1,xcmlloop
  52.         bcs    xcmendp
  53.         bhi    xcmendn
  54.         sub.l    #$10000,D1
  55.         bcc    xcmlloop
  56. xcmlbreak
  57.         move.l    D0,D1        ; get original bytes
  58.         and.l    #3,D1        ; # bytes left to compare
  59.  
  60. xcmbyte     subq.l    #1,D1
  61.         bcs    xcmbbreak
  62. xcmbloop    cmpm.b    (A0)+,(A1)+
  63.         dbne    D1,xcmbloop
  64.         bcs    xcmendp
  65.         bhi    xcmendn
  66.         sub.l    #$10000,D1
  67.         bcc    xcmbloop
  68. xcmbbreak
  69. xcmend0     moveq.l #0,D0
  70.         rts
  71. xcmendp     moveq.l #1,D0
  72.         rts
  73. xcmendn     moveq.l #-1,D0
  74.         rts
  75.  
  76.         END
  77.  
  78.  
  79.  
  80.